﻿package mortal.game.view.chat.smallChat
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import fl.controls.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.game.view.common.*;

    public class SmallChatView extends GSprite
    {
        private var _scrollPane:GScrollPane;
        private var _scrollPaneW:int;
        private var _scrollPaneH:int;
        private var _body:Sprite;

        public function SmallChatView(param1:int, param2:int)
        {
            this._scrollPaneW = param1;
            this._scrollPaneH = param2;
            return;
        }// end function

        private function onPaneMouseDownHandler(event:MouseEvent) : void
        {
            event.stopImmediatePropagation();
            return;
        }// end function

        public function update(param1:Object, ... args) : void
        {
            var _loc_4:int = 0;
            var _loc_6:SmallChatCellRenderer = null;
            args = param1 as Array;
            var _loc_5:* = args.length;
            DisplayUtil.removeAllChild(this._body);
            var _loc_7:int = 0;
            while (_loc_7 < _loc_5)
            {
                
                _loc_6 = new SmallChatCellRenderer();
                _loc_6.setData(args[_loc_7], this._scrollPaneW - 20);
                _loc_6.y = _loc_4;
                this._body.addChild(_loc_6);
                _loc_4 = _loc_4 + _loc_6.height;
                _loc_7++;
            }
            this._scrollPane.update();
            this._scrollPane.drawNow();
            this.addChild(this._scrollPane);
            return;
        }// end function

        public function maxScrollPosition() : void
        {
            this._scrollPane.verticalScrollPosition = this._scrollPane.maxVerticalScrollPosition;
            return;
        }// end function

        public function set scrollPaneW(param1:int) : void
        {
            this._scrollPaneW = param1;
            return;
        }// end function

        public function set scrollPaneH(param1:int) : void
        {
            this._scrollPaneH = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._body = UIFactory.sprite();
            this.addChild(this._body);
            this._scrollPane = UICompomentPool.getUICompoment(GScrollPane);
            this._scrollPane.verticalScrollBarPos = GScrollPane.SCROLLBARPOSITIONRIGHT;
            this._scrollPane.x = 0;
            this._scrollPane.y = 0;
            this._scrollPane.width = this._scrollPaneW;
            this._scrollPane.height = this._scrollPaneH;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.ON;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            this._scrollPane.mouseEnabled = false;
            this._scrollPane.source = this._body;
            this._scrollPane.addEventListener(MouseEvent.MOUSE_DOWN, this.onPaneMouseDownHandler);
            this.addChild(this._scrollPane);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            UIFactory.disposeSprite(this._body, true);
            this._scrollPane.dispose(param1);
            this._body = null;
            this._scrollPane = null;
            return;
        }// end function

    }
}
